package lab01;

import java.util.Scanner;

public class Test08 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //随机生成一个数在1-100之间
        int number = (int) (Math.random() * 100) + 1;
        int count = 0;
        for (int i = 1; i < 20; i++) {//循环

            System.out.println("请输入1-100的数:");

            int x = sc.nextInt();
            count++;//记录次数
            if (x > number) {
                System.out.println("大了");
            } else if (x < number) {
                System.out.println("小了");
            } else {
                System.out.println("对了");
                System.out.println("count=" + count);
                break;
            }
        }
    }
}
